﻿using LibNiconico.NiconicoApi.Extentions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace LibNiconico.NiconicoApi.Alert
{
    /// <summary>
    /// ニコニコアラートメッセージサーバー
    /// </summary>
    public class NicoAlertMessageServer
    {
        /// <summary>
        /// アドレス
        /// </summary>
        public string Addr
        {
            get;
            private set;
        }

        /// <summary>
        /// ポート番号
        /// </summary>
        public int Port
        {
            get;
            private set;
        }


        /// <summary>
        /// スレッドID
        /// </summary>
        public string Thread
        {
            get;
            private set;
        }

        internal NicoAlertMessageServer()
        {
            this.Addr = "";
            this.Port = -1;
        }

        internal static NicoAlertMessageServer Parse(XElement element)
        {
            var messageSerever = new NicoAlertMessageServer();

            if (element != null)
            {
                messageSerever.Addr = XElementExtention.GetElementAsString(element, "addr");
                messageSerever.Port = XElementExtention.GetElementAsInt(element, "port");
                messageSerever.Thread = element.GetElementAsString("thread");
            }
            return messageSerever;
        }


    }
}
